import type { RouteLocationNormalized } from 'vue-router'
import useKeepalive from '~/composables/keepalive'
import { useUserStore } from '../stores/user'

export default defineNuxtRouteMiddleware((to: RouteLocationNormalized) => {
  if (to.meta && to.meta.keepalive)
    useKeepalive().addRoute(to)

  
  // const userStore = useUserStore()
  // // 添加登录验证逻辑
  // const authRoutes = ['/recharge', '/my'] // 需要登录的路由
  // const isAuthRequired = authRoutes.some(route => 
  //   to.path.startsWith(route)
  // )

  // if (isAuthRequired && !userStore.isLogin) {
  //   return navigateTo({
  //     path: '/login',
  //     query: { redirect: to.fullPath }
  //   })
  // }
})
